//2028.找出缺失的观测数据
//https://leetcode.cn/problems/find-missing-observations
class Solution {
public:
    vector<int> missingRolls(vector<int>& rolls, int mean, int n) {
        int sum = 0;
        for(int& x:rolls) sum += x;
        int num = mean*(n+rolls.size());
        //当前数组和是不可能大于总数和的
        if (sum >= num) return {};

        num -= sum;
        //不够分那么多位置
        if(num / n == 0) return {};
        vector<int> ret(n,num/n);
        num -= ((num / n) * n);

        for(int& x:ret)
        {
            if(x == 6) continue;
            if(x+num<=6)
            {
                x += num;
                num = 0;
                break;
            }
            else
            {
                num -= (6-x);
                x = 6;
            }
        }
        if(num) return {};
        return ret;
    }
};